
function codeForToken(code){
    let codeUrl = "http://127.0.0.1:8080/api/token/" + code.toString();
    console.log("codeUrl: " + codeUrl)
    $.ajax({
        url: codeUrl,
        type:"GET",
        headers: {
        },
        contentType:"application/json; charset=utf-8",
        success: function(response){
            console.log(response)
            localStorage.setItem("token", response.access_token)
            console.log(localStorage.getItem("token"))
        },
        error: function (response) {
        }
    })
}

function GetRequest() {
    const url = location.search; //获取url中"?"符后的字串
    console.log(url)
    let theRequest = new Map();
    if (url.indexOf("?") != -1) {
        let str = url.substr(1);
        let strs = str.split("&");
        for(let i = 0; i < strs.length; i ++) {
            theRequest.set(strs[i].split("=")[0], strs[i].split("=")[1])
        }
    }
    return theRequest;
}

export {codeForToken, GetRequest}
